﻿namespace MvcFckEditor.Components
{
    using System;
    using System.Configuration;
    using System.Web.Compilation;

    public abstract class FckProvider
    {
        private static FckProvider objProvider;

        static FckProvider()
        {
            string typeName = ConfigurationManager.AppSettings["FckProvider"];
            objProvider = (FckProvider) Activator.CreateInstance(CreateType(typeName));
        }

        protected FckProvider()
        {
        }

        public static Type CreateType(string TypeName)
        {
            try
            {
                return BuildManager.GetType(TypeName, true, true);
            }
            catch
            {
                return  typeof ( DefaultFckProvider );
              //  return BuildManager.GetType("MvcFckEditor.Components.DefaultFckProvider, CoolCode.Sear", true, true);
            }
        }

        public abstract string GetUserFilesPath();
        public static FckProvider Instance()
        {
            return objProvider;
        }
    }
}

